# Maintainer: Leonardo Arena <rnalrd@alpinelinux.org>
pkgname=milter-greylist
pkgver=4.6.4
pkgrel=3
pkgdesc="Stand-alone milter written in C that implements the greylist filtering method"
url="http://hcpnet.free.fr/milter-greylist"
arch="all"
license="BSD-3-Clause"
makedepends="bison flex libmaxminddb-dev libmilter-dev libspf2-dev opendkim-dev openssl-dev>3"
install="$pkgname.pre-install"
subpackages="$pkgname-doc $pkgname-openrc"
pkgusers="smmsp"
pkggroups="smmsp"
options="!check" # no test suite
source="https://ftp.espci.fr/pub/milter-greylist/milter-greylist-$pkgver.tgz
	milter-greylist-conf.patch
	milter-greylist.initd
	"

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--localstatedir=/var/lib \
		--with-libspf2 \
		--with-user=smmsp \
		--with-conffile=/etc/$pkgname/greylist.conf \
		--with-dumpfile=/var/lib/$pkgname/greylist.db \
		--with-thread-safe-resolver \
		--with-libmaxminddb \
		--with-libopendkim=/usr/include/opendkim \
		--enable-postfix \
		--enable-spamassassin \
		--enable-dnsrbl \
		--disable-rpath
	make
}

package() {
	make DESTDIR="$pkgdir" install
	install -m755 -D "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
	install -m644 -D greylist2.conf "$pkgdir"/etc/$pkgname/greylist2.conf
	mkdir -p "$pkgdir"/var/lib/$pkgname
	chown -R smmsp:smmsp "$pkgdir"/var/lib/$pkgname
}

sha512sums="a52984e89b78a8c9ec89004d1ef0d3cc1e91ccce63b73774a616868a6c64565a393e77dcb29e20a4340d0a23850ce0c261725aef7a3bb607ea4049a1cd78c20c  milter-greylist-4.6.4.tgz
4057061fae24a8d008c6a8aed82018a4bb9f6e9ce72a13d9369d54b192e9a6e99b0e72db8905aa182879c9522b87a92844d0be92773843773508a21e42dbd447  milter-greylist-conf.patch
63f9e24d894980388cb5e5ae34e3adb5f9b5fa167e77c290fe72587002366c225a2fa9607d322eaa485c98cbdd68e14bdaa4b91ad46083f5f3a409eb5e6103f9  milter-greylist.initd"
